package ai.people.platform.system.controller;

import ai.people.netmon.framework.domain.system.request.NmSystemRoleUserRequest;
import ai.people.netmon.framework.model.response.Result;
import ai.people.netmon.framework.utils.ResultUtil;
import ai.people.platform.system.service.SysRoleMenuService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 角色菜单接口
 *
 * @author zhenglin
 * @since 2022/3/22
 */
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/roleMenu")
public class SystemRoleMenuController {

    /**
     * 系统角色菜单服务
     */
    private final SysRoleMenuService sysRoleMenuService;


    /**
     * 保存角色菜单
     *
     * @param nmSystemRoleUserRequest 系统角色用户请求
     * @return {@link Result}<{@link Boolean}>
     * @mock [1, 2, 3]
     */
    @PostMapping
    public Result<Boolean> saveRoleMenu(@Validated @RequestBody NmSystemRoleUserRequest nmSystemRoleUserRequest) {
        sysRoleMenuService.saveRoleMenu(nmSystemRoleUserRequest.getRoleId(), nmSystemRoleUserRequest.getMenuIds());
        return ResultUtil.success();
    }

}
